package com.zuihai.app.mvp.model;

import android.app.Application;

import com.google.gson.Gson;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.zuihai.app.mvp.contract.AdCommentContract;
import com.zuihai.app.mvp.model.api.my.IMy;
import com.zuihai.app.mvp.model.entity.BaseMain;
import com.zuihai.app.mvp.model.entity.BaseMainClass;
import com.zuihai.app.mvp.model.entity.MyWalletMainClass;
import com.zuihai.app.mvp.model.entity.ad.GuanggaoDetailData;

import javax.inject.Inject;

import rx.Observable;

/**
 * 通过Template生成对应页面的MVP和Dagger代码,请注意输入框中输入的名字必须相同
 * 由于每个项目包结构都不一定相同,所以每生成一个文件需要自己导入import包名,可以在设置中设置自动导入包名
 * 请在对应包下按以下顺序生成对应代码,Contract->Model->Presenter->Activity->Module->Component
 * 因为生成Activity时,Module和Component还没生成,但是Activity中有它们的引用,所以会报错,但是不用理会
 * 继续将Module和Component生成完后,编译一下项目再回到Activity,按提示修改一个方法名即可
 * 如果想生成Fragment的相关文件,则将上面构建顺序中的Activity换为Fragment,并将Component中inject方法的参数改为此Fragment
 */

/**
 * Created by Panda_Program on 2018/7/21 0021.
 */

@FragmentScope
public class AdCommentModel extends BaseModel implements AdCommentContract.Model {
    private Gson mGson;
    private Application mApplication;
    private IMy iMy;

    @Inject
    public AdCommentModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
        super(repositoryManager);
        this.mGson = gson;
        this.mApplication = application;
        iMy= repositoryManager.obtainRetrofitService(IMy.class);

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<BaseMain<GuanggaoDetailData>> guanggaoDetail(String myID) {
        return iMy.guanggaoDetail(myID);
    }

    @Override
    public Observable<MyWalletMainClass> requestWallet(String my_id) {
        return iMy.getWalletData(my_id,1);
    }

    @Override
    public Observable<BaseMainClass> requestAd(String id) {
        return iMy.requestAd(id);
    }
}
